/*
 * @Author: qianmingtian
 * @Date: 2020-07-09 09:49:42
 * @LastEditors: qianmingtian
 * @LastEditTime: 2020-07-09 15:51:41
 * @FilePath: \qianmingtian.github.io\code\java\ArraySimStack.java
 */
public class ArraySimStack {

    private Object[] element;

    private int index;

    public ArraySimStack() {
        this.element = new Object[10];
        this.index = -1;

    }

    public void push(Object obj) {
        if (index >= element.length - 1) {
            System.out.println("栈已满");
            return;
        }

        index++;
        element[index] = obj;

        System.out.println("压栈" + obj.toString() + "成功，到" + index);
    }

    public Object pop() {
        Object eleObject = new Object();
        if (index < 0) {
            System.out.println("栈已空");
            return null;

        }

        eleObject = element[index];
        System.out.println(element[index] + "出栈" + index);
        index--;

        return eleObject;
    }

    public Object[] getElement() {
        return element;
    }

    public void setElement(Object[] element) {
        this.element = element;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

}/*
  * @Author: qianmingtian
  * 
  * @Date: 2020-07-09 09:49:42
  * 
  * @LastEditors: qianmingtian
  * 
  * @LastEditTime: 2020-07-09 09:49:43
  * 
  * @FilePath: \qianmingtian.github.io\code\java\ArraySimStack.java
  */
